#!/usr/bin/python
import wx
import urllib
from time import time, localtime
from datetime import datetime

class Move(wx.Frame):

	def __init__(self, parent, id, title):
		wx.Frame.__init__(self, parent, id, title, style = wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP | wx.FRAME_TOOL_WINDOW | ~wx.CLIP_CHILDREN, size=(96,24))
		try:
			f = urllib.urlopen("http://www/ncdsis/laboratorio/sessao/get_horario/meu")
			login,self.passou,tempo,lixo =  f.read().split('\n')
			
		except:
			self.passou='0'

		self.tempoini = datetime.now()
		
		self.passou = int(self.passou)
		self.horario=wx.StaticText(self, -1,str(self.passou),style= wx.ALIGN_CENTER)
		
		self.timer = wx.Timer(self)
		self.timer.Start(1000)
		self.Bind(wx.EVT_TIMER,self.horas,self.timer)

	def horas(self,evt):
		tempofim=datetime.now()
		tempoatual=tempofim-self.tempoini
		tempoatual= tempoatual.seconds+self.passou
		hora = tempoatual/3600
		minuto = (tempoatual/60)%60
		segundo = tempoatual%60
		self.horario.SetLabel ('%02d:%02d:%02d' %(hora, minuto, segundo))
		fonte = wx.Font(13, wx.DEFAULT, wx.NORMAL, ~wx.BOLD)
		self.horario.SetFont(fonte)
		obj = wx.ScreenDC()
		resolucao = obj.GetSize()
		horizontal = resolucao[0]
		self.Move((horizontal-160, 0))
		self.Show(True)


app = wx.App()
Move(None, -1, 'Relogio')
app.MainLoop()

